package applicationFunction.hessian.helloWorld;

import com.caucho.hessian.server.HessianServlet;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

/**
 * @author away
 */
public class BasicService extends HessianServlet implements BasicAPI {
    static{
        try {
            initLog();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
    }
    private String greeting = "Hello, world";


    public void setGreeting(String greeting)
    {
        this.greeting = greeting;
    }

    @Override
    public String hello()
    {

        try{
            Integer i = Integer.parseInt("ss");
        }catch (Exception e){
            throw new RuntimeException("aaaaaaa");
        }
        return greeting;
    }


    public static void initLog() throws IOException {
        Logger logger = Logger.getLogger("");
        System.setProperty("java.util.logging.SimpleFormatter.format","%1$s # %2$s # %3$s # %4$s # %5$s # %6$s%n");
        logger.setLevel(Level.ALL);
        FileHandler fileHandler = new FileHandler("hessianServer.log");
        SimpleFormatter sf = new SimpleFormatter();
        fileHandler.setFormatter(sf);
        logger.addHandler(fileHandler);
    }
}
